package com.company.cuobuliao.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.print.PageRange;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import com.company.cuobuliao.R;
import com.company.cuobuliao.adapter.HomeTeacherAdapter;
import com.company.cuobuliao.application.MyApplication;
import com.company.cuobuliao.base.BaseFragment;
import com.company.cuobuliao.model.HomeInfo;
import com.company.cuobuliao.ui.home.ChooseTimeActivity;
import com.company.cuobuliao.ui.user.MeActivity;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Oreo on 2017/8/14.
 */

public class Fragment1 extends BaseFragment {

    private View view;
    private ListView listView;
    private List<HomeInfo> list = new ArrayList<>();
    private HomeTeacherAdapter adapter;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
//        ContextHelper.init((MyApplication) getActivity().getApplication());
        if (view == null) {
            view = inflater.inflate(R.layout.fragment_home1, container, false);
            initView();
            fucGetData();
        }
        return view;
    }

    private void initView() {
        listView = (ListView) view.findViewById(R.id.listView);
        adapter = new HomeTeacherAdapter(getActivity(), list);
        listView.setAdapter(adapter);

        view.findViewById(R.id.rllyShare).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(getActivity(), MeActivity.class));
            }
        });

        view.findViewById(R.id.lilyTime).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(getActivity(), ChooseTimeActivity.class));
            }
        });
    }

    private void fucGetData() {
        list.add(new HomeInfo());
        list.add(new HomeInfo());
        adapter.notifyDataSetChanged();
    }

}
